﻿@{
    ViewBag.Title = "Setting";
}

@model List<CMSApplication.Areas.Administration.Models.SettingModel>
<script type="text/javascript">
    $(document).ready(function () {
        $("a.delete").click(function () {
            var $this = $(this);
            var NameItem = $this.closest('tr').find('.spanName').html();
            if (confirm("Are you sure delete setting : " + NameItem + "")) {
                var IdItem = $this.closest('tr').find('.Spanid').html();
                $.get("/Administration/Setting/DeleteSetting?id=" + IdItem, function () {
                    $.get("/Administration/Setting/ListSetting", function (data) {
                        $(".list").html("");
                        $(".list").html(data);
                    });
                });
            }
        });

    });

</script>
@if (Model.Count() > 0)
{
    <table class="table" style="width:100%">
        <thead>
            <th>
                Setting Name
            </th>
            <th>
                Title
            </th>
            <th width="50px">
                Action
            </th>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <span class="Spanid" style="display: none;">@item.Id</span> 
                        <span class="spanName">@item.SettingName
                        </span>
                    </td>
                    <td>
                    @if (!String.IsNullOrEmpty(item.Title))
                    {
                        <span>@item.Title</span>
                    }
                    else
                    {
                        <span>No Title.</span>
                    }
                    </td>
                    <td>
                          <a href="@Url.Action("EditSetting", "Setting", new { id = item.Id })" class="icon-pencil"></a>
                         <a href="javascript:void(0)" class="icon-trash delete"></a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <h2>
        No Setting.
    </h2>
}

